package com.zn.product.controller;


import  javax.servlet.annotation.WebServlet;
import com.zn.product.dao.ProductDao;
import com.zn.product.model.Product;
import com.zn.product.service.ProductService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/productMsg.do")
public class ProductinfoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        ProductService service = new ProductService();
        //使用服务层对象获取商品信息
        Product product = service.getProductById(id);
        //将信息存储到请求对象中
        req.setAttribute("product", product);
        req.getRequestDispatcher("product.jsp").forward(req, resp);

    }
}
